package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 我的游记
 */
@Getter@Setter
public class Travel extends BaseDomain{
    public static final int STATE_REJECT = -1; //拒绝
    public static final int STATE_NOMAL = 0; //草稿
    public static final int STATE_WAIT = 1; //待发布
    public static final int STATE_RELEASE = 2; //已发布
    private String title;//标题
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")//后台传给前台
    private Date travelTime;//旅游时间

    private String perExpends;//人均消费

    private Integer days;//旅游天数

    private Integer person;//和谁一起旅游

    private User author;//作者

    private Date createTime;//创建时间

    private Date releaseTime;//发布时间

    private Boolean isPublic;//是否公布

    private Region place;//地区

    private String coverUrl;//封面
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date lastUpdateTime;//最后更新时间

    private Integer state;//状态

    private TravelContent travelContent;//游记内容

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title",title);
        map.put("coverUrl",coverUrl);
        return JSONUtil.toJSONString(map);
    }
}